package com.instwall.callnumzigbee.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

import com.instwall.callbase.tool.LogUtil;
import com.instwall.callnumzigbee.ZigBeeConfig;

public class MyReceiver extends BroadcastReceiver {

    public static ReceiverListener listener;

    @Override
    public void onReceive(Context context, Intent intent) {

        LogUtil.LogI(ZigBeeConfig.STAG,"MyReceiver");
        if (intent.getAction().equals(ZigBeeConfig.BROADCAST)){
            LogUtil.LogI(ZigBeeConfig.STAG,"MyReceiver is ok ");
            String msg = intent.getStringExtra(ZigBeeConfig.INTENT_ACTION_NAME);
            if(TextUtils.isEmpty(msg)){
                msg = "Test";
            }
            if(listener!=null){
                listener.MessageReceiver(msg);
            }
        }
    }

    public static void setListener(ReceiverListener ltr){
        listener = ltr;
    }


    public interface  ReceiverListener {
        void MessageReceiver(String msg);
    }
}
